import { ref } from 'vue';
import { defineStore } from 'pinia';


export const useOrderStore = defineStore('order', 
  () => {
    const orderId = ref(null);
    const amount = ref(null);
    const channel = ref(null);

    function setOrderInfo(new_orderId,new_amount,new_channel){
      orderId.value = new_orderId;
      amount.value = new_amount;
      channel.value = new_channel;
    }
    
    return { orderId, amount, channel, setOrderInfo}
  }, 
  {
    persist:[
      {
        enabled:true,
        strategies:[
          {
            paths:['orderId','amount','channel'],
            storage:localStorage
          }
        ]
      }
    ]
  }
);


export const useProductStore = defineStore('product', 
  () => {
    const productId = ref(null);

    function setProductInfo(new_productId){
      productId.value = new_productId;
    }
    
    return { productId, setProductInfo}
  }, 
  {
    persist:[
      {
        enabled:true,
        strategies:[
          {
            paths:['productId'],
            storage:localStorage
          }
        ]
      }
    ]
  }
);